********************************************************************************
********************************************************************************
* DENTLER, BLINZLER, & QUINLAN 
* "Electoral Messiah or Party Label? Quantifying and Investigating Leader-Party 
* Relationships in German Federal Elections 1998-2021"
* Analysis: Leader or Party Evaluations - Which Matters More? 
* (Including analysis in the Paper's Appendixes)
* Syntax to be run on German Longitudinal Election Study (GLES) Rolling Cross-
* Sectional (Panel) Data 2021.  
* Last updated: Tuesday October 31, 2023. 
********************************************************************************
********************************************************************************


********************************************************************************
********************************************************************************
* SYNTAX FILE TABLE OF CONTENTS
* #>>>  1: INSTRUCTIONS FOR USE OF SYNTAX FILE, PURPOSE OF SYNTAX FILE
**         GET DATA, & STATA SETUP FOR TIME SERIES 
* #>>>  2: VARIABLE CLEAN UP AND ADDITIONAL VARIABLES CREATED FOR ANALYSIS
**>>>   3: 2021 ROLLING CROSS-SECTION ANALYSIS - SIMULTANEOUS MEASUREMENT 
**         ANALYSIS
**>>>   4: 2021 ROLLING CROSS-SECTION ANALYSIS -RECIPROCAL FEEDBACK ANALYSIS 
**         - REPLICATION OF GARZIA & DE ANGELIS (2016)
**>>>   5: 2021 ROLLING CROSS-SECTION ANALYSIS - INSTRUMENTAL VARIABLE ANALYSIS 
********************************************************************************
********************************************************************************


********************************************************************************
********************************************************************************
**#>>> 1: INSTRUCTIONS FOR USE OF SYNTAX FILE, PURPOSE OF SYNTAX FILE
**        AND STATA SETUP
********************************************************************************
********************************************************************************

********************************************************************************
**// 1.1 INSTRUCTIONS FOR NAVIGATING FILE
********************************************************************************

** #>>> = Section Heading
** //  = Variable or Subsection Heading
** <<< = Sub variable/section heading and/or Instruction 
** ACHTUNG - File Path change may be required


********************************************************************************
**// 1.2 PURPOSE INSTRUCTIONS FOR NAVIGATING FILE
********************************************************************************
* This do-file serves as the replicaton file for analysis concerning for the 
* 2021 GLES Rolling Cross-Sectional analysis (Panel) included in the Dentler, 
* Blinzler, and Quinlan paper "ELECTORAL MESSIAH OR PARTY LABEL? QUANTIFYING 
* AND INVESTIGATING LEADER-PARTY RELATIONSHIPS IN GERMAN FEDERAL ELECTIONS 
* 1998-2021". Most of the analysis contained in this file appears in Section 4
* of the paper and in Appendixes E and H respectively.  


********************************************************************************
**// 1.3 LOADING DATA
** (ACHTUNG: File Path may need ajusting depending on where dataset has been saved)
********************************************************************************
 
clear all 
use "C:\Users\quinlasn\Desktop\Research\Leaders_DE\Data and Syntax\Processed Data\20230601\GLES_RCS2021.dta", clear


********************************************************************************
**// 1.4 INSTALL ADD-ONS FOR STATA
** Please note: Internet connection usually required for installation of add ons
********************************************************************************


*<<< Install coefplot to enable presentation of results in plot format
ssc install coefplot, replace


*<<< Install hsmode for additional summary stats
ssc install hsmode



********************************************************************************
********************************************************************************
**#>>> 2:  VARIABLE CLEAN UP AND ADDITIONAL VARIABLES CREATED FOR ANALYSIS
********************************************************************************
********************************************************************************


********************************************************************************
**// 2.1 REMOVE RESPONDENT DON'T KNOW RESPONSES FROM LEADER LIKE MEASURES t0
********************************************************************************

drop if  LeaderLike_spd_t0==-1
drop if  LeaderLike_cdu_t0==-1
drop if  LeaderLike_green_t0==-1
drop if  LeaderLike_fdp_t0==-1
drop if  LeaderLike_left_t0==-1
drop if  LeaderLike_afd_t0==-1


********************************************************************************
**// 2.2 REMOVE RESPONDENT DON'T KNOW RESPONSES FROM LEADER LIKE MEASURES t1
********************************************************************************

drop if  LeaderLike_spd_t1==-1
drop if  LeaderLike_cdu_t1==-1
drop if  LeaderLike_green_t1==-1
drop if  LeaderLike_fdp_t1==-1
drop if  LeaderLike_left_t1==-1
drop if  LeaderLike_afd_t1==-1


********************************************************************************
**// 2.3 REMOVE RESPONDENT DON'T KNOW RESPONSES FROM PARTY LIKE MEASURES t0
********************************************************************************

drop if  PartyLike_spd_t0==-1
drop if  PartyLike_cdu_t0==-1
drop if  PartyLike_green_t0==-1
drop if  PartyLike_fdp_t0==-1
drop if  PartyLike_left_t0==-1
drop if  PartyLike_afd_t0==-1


********************************************************************************
**// 2.4 REMOVE RESPONDENT DON'T KNOW RESPONSES FROM PARTY LIKE MEASURES t1
********************************************************************************

drop if  PartyLike_spd_t1==-1
drop if  PartyLike_cdu_t1==-1
drop if  PartyLike_green_t1==-1
drop if  PartyLike_fdp_t1==-1
drop if  PartyLike_left_t1==-1
drop if  PartyLike_afd_t1==-1


********************************************************************************
**// 2.5 VARIABLE CREATION: VOTE CHOICE CURRENT ELECTION - LIST (ZWEITSTIMME)
**       SIX MAIN PARTIES - Votes for Others excluded. 
********************************************************************************

gen vote_pl1 =  vote_pl 
recode vote_pl1 (1=1) (4=4) (5=5) (6=6) (7=7) (322=8) (801=.)  
label var vote_pl1 "Vote Choice (Six Main Parties)"
label define vote_pl1_  1 "CDU/CSU", modify
label define vote_pl1_  4 "SPD", modify
label define vote_pl1_  5 "FDP", modify
label define vote_pl1_  6 "Green", modify
label define vote_pl1_  7 "Left", modify
label define vote_pl1_  8 "Afd", modify
lab val vote_pl1 vote_pl1_
tab vote_pl vote_pl1


********************************************************************************
**// 2.6 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**       UNION
********************************************************************************

gen prevvote_Union =  prevvote_pl 
recode prevvote_Union (1=1) (4=0) (5=0) (6=0) (7=0) (322=0) (801=0)  
label var prevvote_Union "Previous Vote Choice: Union"
label define prevvote_Union_  1 "Previous Vote Choice: CDU/CSU", modify
label define prevvote_Union_  0 "Previous Vote Choice: Other", modify
lab val prevvote_Union prevvote_Union_ 
tab prevvote_Union prevvote_pl


********************************************************************************
**// 2.7 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**       SPD
********************************************************************************

gen prevvote_SPD =  prevvote_pl 
recode prevvote_SPD (1=0) (4=1) (5=0) (6=0) (7=0) (322=0) (801=0)  
label var prevvote_SPD "Previous Vote Choice: SPD"
label define prevvote_SPD_  1 "Previous Vote Choice: SPD", modify
label define prevvote_SPD_  0 "Previous Vote Choice: Other", modify
lab val prevvote_SPD prevvote_SPD_ 
tab prevvote_SPD prevvote_pl


********************************************************************************
**// 2.8 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**       FDP
********************************************************************************

gen prevvote_FDP =  prevvote_pl 
recode prevvote_FDP (1=0) (4=0) (5=1) (6=0) (7=0) (322=0) (801=0)  
label var prevvote_FDP "Previous Vote Choice: FDP"
label define prevvote_FDP_  1 "Previous Vote Choice: FDP", modify
label define prevvote_FDP_  0 "Previous Vote Choice: Other", modify
lab val prevvote_FDP prevvote_FDP_ 
tab prevvote_FDP prevvote_pl


********************************************************************************
**// 2.9 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**   GREEN
********************************************************************************

gen prevvote_Green =  prevvote_pl 
recode prevvote_Green (1=0) (4=0) (5=0) (6=1) (7=0) (322=0) (801=0)  
label var prevvote_Green "Previous Vote Choice: Green"
label define prevvote_Green_  1 "Previous Vote Choice: Green", modify
label define prevvote_Green_  0 "Previous Vote Choice: Other", modify
lab val prevvote_Green prevvote_Green_ 
tab prevvote_Green prevvote_pl


********************************************************************************
**// 2.10 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**        LEFT
********************************************************************************

gen prevvote_Left =  prevvote_pl 
recode prevvote_Left (1=0) (4=0) (5=0) (6=0) (7=1) (322=0) (801=0)  
label var prevvote_Left "Previous Vote Choice: Left"
label define prevvote_Left_  1 "Previous Vote Choice: Left", modify
label define prevvote_Left_  0 "Previous Vote Choice: Other", modify
lab val prevvote_Left prevvote_Left_ 
tab prevvote_Left prevvote_pl


********************************************************************************
**// 2.11 VARIABLE CREATION: VOTE CHOICE PREVIOUS ELECTION - LIST (ZWEITSTIMME) 
**        AFD
********************************************************************************

gen prevvote_Afd =  prevvote_pl 
recode prevvote_Afd (1=0) (4=0) (5=0) (6=0) (7=0) (322=1) (801=0)  
label var prevvote_Afd "Previous Vote Choice: Afd"
label define prevvote_Afd_  1 "Previous Vote Choice: Afd", modify
label define prevvote_Afd_  0 "Previous Vote Choice: Other", modify
lab val prevvote_Afd prevvote_Afd_ 
tab prevvote_Afd prevvote_pl


********************************************************************************
**// 2.12 VARIABLE CREATION: TRADE UNION
********************************************************************************

gen tradeunion_member =  tradeunion_hh_member 
recode tradeunion_member (0=0) (1=1) (2=0) (3=1) 
label var tradeunion_member "R Trade Union Membership"
label define tradeunion_member_  0 "R not a trade union member", modify
label define tradeunion_member_  1 "R a trade union member", modify
lab val tradeunion_member tradeunion_member_
tab tradeunion_hh_member tradeunion_member


********************************************************************************
**// 2.13 VARIABLE CREATION: POST-SECONDARY EDUCATION
********************************************************************************

gen education_postsec =  edu_groups 
recode education_postsec (0=0) (1=0) (2=0) (3=1) 
label var education_postsec "Education: Post Secondary or above"
label define education_postsec_  0 "R has not got post secondary or above", modify
label define education_postsec_  1 "R has post secondary or above", modify
lab val education_postsec education_postsec_
tab edu_groups education_postsec


********************************************************************************
**// 2.14 VARIABLE CREATION: SOCIAL MEDIA USE GENERAL
********************************************************************************

gen socialmediauser =  socialmedia_general 
recode socialmediauser (0=0) (1/14=1)  
label var socialmediauser "Social media user"
label define socialmediauser_  0 "R does not use social media", modify
label define socialmediauser_  1 "R uses social media", modify
lab val socialmediauser socialmediauser_
tab socialmedia_general socialmediauser


********************************************************************************
********************************************************************************
**>>> 3: 2021 ROLLING CROSS-SECTION ANALYSIS - SIMULTANEOUS MEASUREMENT ANALYSIS 
********************************************************************************
********************************************************************************


********************************************************************************
**// 3.1 SIMULTANEOUS MEASUREMENT ANALYSIS - MULTINOMIAL MODEL: VOTE CHOICE 
**       WITH WEIGHTS
** Dependent Variable Base: Union 
** Principal Independent Variables: Leader Likeability t0; Party Likeability t1.
** Analysis detailed in Appendix E - Table E2.1 & Figure 5 in the paper  
********************************************************************************


** <<< Logit Regression Model With Weights (Table E2.1)
eststo RCS_SMA_Multinomial1 : mlogit vote_pl1 female age edu_groups church_attendance east lr_self LeaderLike_cdu_t0 PartyLike_cdu_t1 LeaderLike_spd_t0 PartyLike_spd_t1 LeaderLike_green_t0 PartyLike_green_t1 LeaderLike_fdp_t0 PartyLike_fdp_t1 LeaderLike_left_t0 PartyLike_left_t1  LeaderLike_afd_t0 PartyLike_afd_t1  [pweight=panel2_weight],  baseoutcome(1)
estat ic


** <<< Predicted Probabilites: CDU Leader Likeability t0 (Figure 5 in paper, Top Left Panel)
margins, at(LeaderLike_cdu_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: CDU Party Likeability t1 (Figure 5 in paper, Top Left Panel)
margins, at(PartyLike_cdu_t1=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: SPD Leader Likeability t0 (Figure 5 in paper, Top Right Panel)
margins, at(LeaderLike_spd_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: SPD Party Likeability t1 (Figure 5 in paper, Top Right Panel)
margins, at(PartyLike_spd_t1=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Green Leader Likeability t0 (Figure 5 in paper, Bottom Panel)
margins, at(LeaderLike_green_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Green Party Likeability t1 (Figure 5 in paper, Top Right Panel)
margins, at(PartyLike_green_t1=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: FDP Leader Likeability t0 
margins, at(LeaderLike_fdp_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: fdp Party Likeability t1 
margins, at(PartyLike_fdp_t1=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Left Leader Likeability t0 
margins, at(LeaderLike_left_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Left Party Likeability t1 
margins, at(PartyLike_left_t1=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Afd Leader Likeability t0 
margins, at(LeaderLike_Afd_t0=(0(1)10)) 
marginsplot 


** <<< Predicted Probabilites: Afd Party Likeability t1 
margins, at(PartyLike_Afd_t1=(0(1)10)) 
marginsplot 


********************************************************************************
**// 3.2 SIMULTANEOUS MEASUREMENT ANALYSIS - MULTINOMIAL MODEL: VOTE CHOICE WITHOUT WEIGHTS
** Dependent Variable Base: Union 
** Principal Independent Variables: Leader Likeability t0; Party Likeability t1.
** Analysis detailed in Appendix E - Table E2.2 
********************************************************************************

** <<< Logit Regression Model Without Weights (Table E2.2)
eststo RCS_SMA_Multinomial2 : mlogit vote_pl1 female age edu_groups church_attendance east lr_self LeaderLike_cdu_t0 PartyLike_cdu_t1 LeaderLike_spd_t0 PartyLike_spd_t1 LeaderLike_green_t0 PartyLike_green_t1 LeaderLike_fdp_t0 PartyLike_fdp_t1 LeaderLike_left_t0 PartyLike_left_t1  LeaderLike_afd_t0 PartyLike_afd_t1,  baseoutcome(1)
estat ic


********************************************************************************
**// 3.3 TRANSFER MODELS OUTPUT TO TABLES IN MS WORD 
********************************************************************************

esttab RCS_SMA_Multinomial1 using table_RCS_SMA_Multinomial.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table E2.1) nonumbers mtitles("RCS: SMA")  replace
 
esttab RCS_SMA_Multinomial2 using table_RCS_SMA_Multinomial_WithoutWeights.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table E2.2) nonumbers mtitles("RCS: SMA Without Weights")  replace
 

 
********************************************************************************
********************************************************************************
**>>> 4: 2021 ROLLING CROSS-SECTION ANALYSIS -RECIPROCAL FEEDBACK ANALYSIS 
**       - REPLICATION OF GARZIA & DE ANGELIS (2016)
** Testing Reciprocal Feedback by Controlling for Previous Vote Choice in models
** Analysis detailed in Appendix H - Tables H1.1 & H1.2 (Main) and H7.1 & H7.2 (Robustness)
********************************************************************************
********************************************************************************

********************************************************************************
**// 4.1 RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE UNION WITH 
**       WEIGHTS
** Principal Independent Variables: CDU Leader Likeability t0; CDU Party Likeability t0.
** Analysis detailed in Appendix H - Table H1.1 & H1.2 & Figure H1 (Top Left) 
********************************************************************************


** <<< Logit Regression Model With Weights: Union (Table H1.1, Column 1)
eststo GDA_CDU :logit vote_union age female high_school church_attendance east lr_self PartyLike_cdu_t0 LeaderLike_cdu_t0 prevvote_Union [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: Union  (Table H1.2, Row 1)
margins, dydx(PartyLike_cdu_t0)
margins, dydx(LeaderLike_cdu_t0)


** <<<  Predicted Probabilites: Union  (Figure H1, Top Left)
margins, at(PartyLike_cdu_t0=(0(1)10)) 
margins, at(LeaderLike_cdu_t0=(0(1)10)) 
tab PartyLike_cdu_t0 [aweight=panel2_weight]
tab LeaderLike_cdu_t0 [aweight=panel2_weight]


********************************************************************************
**// 4.2 RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE SPD WITH WEIGHTS
** Principal Independent Variables: SPD Leader Likeability t0; SPD Party Likeability t0.
** Analysis detailed in Appendix H - Table H1.1 & H1.2 & Figure H1 (Top Right) 
********************************************************************************

** <<< Logit Regression Model With Weights: SPD (Table H1.1, Column 2)
eststo GDA_SPD :logit vote_spd age female high_school church_attendance east lr_self PartyLike_spd_t0 LeaderLike_spd_t0 prevvote_SPD [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: SPD (Table H1.2, Row 2)
margins, dydx(PartyLike_spd_t0)
margins, dydx(LeaderLike_spd_t0)


** <<<  Predicted Probabilites: SPD  (Figure H1, Top Right)
margins, at(PartyLike_spd_t0=(0(1)10)) 
margins, at(LeaderLike_spd_t0=(0(1)10)) 
tab LeaderLike_spd_t0 [aweight=panel2_weight]
tab PartyLike_spd_t0 [aweight=panel2_weight]


********************************************************************************
**// 4.3 RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE GREEN WITH WEIGHTS
** Principal Independent Variables: Green Leader Likeability t0; Green Party Likeability t0.
** Analysis detailed in Appendix H - Table H1 (Column 3)
********************************************************************************

** <<< Logit Regression Model With Weights: Greens (Table H1.1, Column 3)
eststo GDA_Green :logit vote_green age female high_school church_attendance east lr_self PartyLike_green_t0 LeaderLike_green_t0 prevvote_Green [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: Green (Table H1.2, Row 3)
margins, dydx(PartyLike_green_t0)
margins, dydx(LeaderLike_green_t0)


** <<<  Predicted Probabilites: Green  (Figure H1, Bottom Left)
margins, at(PartyLike_green_t0=(0(1)10)) 
margins, at(LeaderLike_green_t0=(0(1)10)) 
tab PartyLike_green_t0 [aweight=panel2_weight]
tab LeaderLike_green_t0 [aweight=panel2_weight]


********************************************************************************
**// 4.4 RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE FDP WITH WEIGHTS
** Principal Independent Variables: FDP Leader Likeability t0; FDP Party Likeability t0.
** Analysis detailed in Appendix H - Table H1 (Column 4)
********************************************************************************

** <<< Logit Regression Model With Weights: FDP (Table H1.1, Column 4)
eststo GDA_FDP :logit vote_fdp age female high_school church_attendance east lr_self PartyLike_fdp_t0 LeaderLike_fdp_t0 prevvote_FDP [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: FDP (Table H1.2, Row 4)
margins, dydx(PartyLike_fdp_t0)
margins, dydx(LeaderLike_fdp_t0)


** <<<  Predicted Probabilites: FDP  (Figure H1, Bottom Right)
margins, at(PartyLike_fdp_t0=(0(1)10)) 
margins, at(LeaderLike_fdp_t0=(0(1)10)) 
tab PartyLike_fdp_t0 [aweight=panel2_weight]
tab LeaderLike_fdp_t0 [aweight=panel2_weight]


********************************************************************************
**// 4.5 TRANSFER MODELS OUTPUT TO TABLES IN MS WORD 
********************************************************************************

esttab GDA_CDU GDA_SPD GDA_Green GDA_FDP using table_GDA.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H1.1) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace


********************************************************************************
**// 4.6 **ROBUSTNESS** RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE UNION WITH WEIGHTS
** Robustness tests use CDU Party Likeability at t1 instead of t0
** Principal Independent Variables: CDU Leader Likeability t0; CDU Party Likeability t1.
** Analysis detailed in Appendix H - Table H7 (Column 1)
********************************************************************************

eststo GDA_CDU_ROBO :logit vote_union age female high_school church_attendance east lr_self PartyLike_cdu_t1 LeaderLike_cdu_t0 prevvote_Union [pweight=panel2_weight]
estat ic 


********************************************************************************
**// 4.7 **ROBUSTNESS** RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE SPD WITH WEIGHTS
** Robustness tests use SPD Party Likeability at t1 instead of t0
** Principal Independent Variables: SPD Leader Likeability t0; SPD Party Likeability t1.
** Analysis detailed in Appendix H - Table H7 (Column 2)
********************************************************************************

eststo GDA_SPD_ROBO :logit vote_spd age female high_school church_attendance east lr_self PartyLike_spd_t1 LeaderLike_spd_t0 prevvote_SPD [pweight=panel2_weight]
estat ic 


********************************************************************************
**// 4.8 **ROBUSTNESS**  RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE GREEN WITH WEIGHTS
** Robustness tests use Green Party Likeability at t1 instead of t0
** Principal Independent Variables: Green Leader Likeability t0; Green Party Likeability t1.
** Analysis detailed in Appendix H - Table H7 (Column 3)
********************************************************************************

eststo GDA_Green_ROBO :logit vote_green age female high_school church_attendance east lr_self PartyLike_green_t1 LeaderLike_green_t0 prevvote_Green [pweight=panel2_weight]
estat ic 


********************************************************************************
**// 4.9 **ROBUSTNESS**  RECIPROCAL FEEDBACK ANALYSIS - LOGIT MODEL: VOTE CHOICE FDP WITH WEIGHTS
** Robustness tests use FDP Likeability at t1 instead of t0
** Principal Independent Variables: FDP Leader Likeability t0; FDP Party Likeability t1.
** Analysis detailed in Appendix H - Table H7 (Column 4)
********************************************************************************

eststo GDA_FDP_ROBO :logit vote_fdp age female high_school church_attendance east lr_self PartyLike_fdp_t1 LeaderLike_fdp_t0 prevvote_FDP [pweight=panel2_weight]
estat ic 


********************************************************************************
**// 4.10 TRANSFER MODELS OUTPUT TO TABLES IN MS WORD - ROBUSTNESS ANALYSIS
********************************************************************************

esttab GDA_CDU_ROBO GDA_SPD_ROBO GDA_Green_ROBO GDA_FDP_ROBO using table_GDA.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H7.1) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace


********************************************************************************
********************************************************************************
**>>> 5: 2021 ROLLING CROSS-SECTION ANALYSIS - INSTRUMENTAL VARIABLE ANALYSIS 
** Analysis detailed in Appendix H - Tables H2-H6 (Main)
********************************************************************************
********************************************************************************

********************************************************************************
**// 5.1 CREATING INSTRUMENTAL VARIABLES: EXOGENIZING PARTY LIKEABILITY T-1 
**       FOR EACH BLOC
** Analysis for each party detailed in Appendix H - Tables H2 and H3
** Correlation analysis between original measure and exogenized measure detailed in Appendix H - Table H2.  
********************************************************************************

** <<< Union: Instrumental Variable Creation of Exogenized Party Likeability t1 (Detailed in Table H3, Column 1)
eststo ExogPartyLikeT1CDU :reg PartyLike_cdu_t1 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_union exp_coalition_union pol_interest attitude_debtbrake attitude_elec_integrity[pweight=panel2_weight]
predict PartyLike_cdu_t1hat1


** <<< Union: Correlation between Party Likeability t1 and Exogenized Party Likeability t1 (Detailed in Table H2, Column 2, Row 1)
corr PartyLike_cdu_t1hat1 PartyLike_cdu_t1 


** <<< SPD: Instrumental Variable Creation of Exogenized Party Likeability t1 (Detailed in Table H3, Column 2)
eststo ExogPartyLikeT1SPD :reg PartyLike_spd_t1 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_spd exp_coalition_spd pol_interest attitude_debtbrake attitude_elec_integrity [pweight=panel2_weight]
predict PartyLike_spd_t1hat1


** <<< SPD: Correlation between Party Likeability t1 and Exogenized Party Likeability t1 (Detailed in Table H2, Column 2, Row 2)
corr PartyLike_spd_t1hat1 PartyLike_spd_t1


** <<< Green: Instrumental Variable Creation of Exogenized Party Likeability t1 (Detailed in Table H3, Column 3)
eststo ExogPartyLikeT1Green :reg PartyLike_green_t1 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_green exp_coalition_green pol_interest attitude_debtbrake attitude_elec_integrity [pweight=panel2_weight]
predict PartyLike_green_t1hat1


** <<< SPD: Correlation between Party Likeability t1 and Exogenized Party Likeability t1 (Detailed in Table H2, Column 2, Row 3)
corr PartyLike_green_t1hat1 PartyLike_green_t1


** <<< FDP: Instrumental Variable Creation of Exogenized Party Likeability t1 (Detailed in Table H3, Column 4)
eststo ExogPartyLikeT1FDP :reg PartyLike_fdp_t1 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_union exp_coalition_union pol_interest attitude_debtbrake attitude_elec_integrity [pweight=panel2_weight]
predict PartyLike_fdp_t1hat1


** <<< FDP: Correlation between Party Likeability t1 and Exogenized Party Likeability t1 (Detailed in Table H2, Column 2, Row 4)
corr PartyLike_fdp_t1hat1 PartyLike_fdp_t1


** <<< TRANSFER MODEL OUTPUT TO TABLES IN MS WORD
esttab ExogPartyLikeT1CDU ExogPartyLikeT1SPD ExogPartyLikeT1Green ExogPartyLikeT1FDP using table_ExogPartyLike.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H3) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace


********************************************************************************
**// 5.2 CREATING INSTRUMENTAL VARIABLES: EXOGENIZING LEADER LIKEABILITY T-0 
**       FOR EACH BLOC
** Analysis for each party detailed in Appendix H - Tables H2 and H4
** Correlation analysis between original measure and exogenized measure detailed in Appendix H - Table H2.  
********************************************************************************


** <<< Union: Instrumental Variable Creation of Exogenized Leader Likeability t0 (Detailed in Table H4, Column 1)
eststo ExogLeaderLikeT0CDU :reg LeaderLike_cdu_t0 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_union exp_coalition_union pol_interest attitude_debtbrake attitude_elec_integrity [pweight=panel2_weight]
predict LeaderLike_cdu_t0hat1


** <<< Union: Correlation between Leader Likeability t0 and Exogenized Leader Likeability t0 (Detailed in Table H2, Column 1, Row 1)
corr LeaderLike_cdu_t0hat1 LeaderLike_cdu_t0


** <<< SPD: Instrumental Variable Creation of Exogenized Leader Likeability t0 (Detailed in Table H4, Column 2)
eststo ExogLeaderLikeT0SPD :reg LeaderLike_spd_t0 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_spd exp_coalition_spd pol_interest attitude_debtbrake attitude_elec_integrity[pweight=panel2_weight]
predict LeaderLike_spd_t0hat1


** <<< SPD: Correlation between Leader Likeability t0 and Exogenized Leader Likeability t0 (Detailed in Table H2, Column 1, Row 2)
corr LeaderLike_spd_t0hat1 LeaderLike_spd_t0


** <<< Green: Instrumental Variable Creation of Exogenized Leader Likeability t0 (Detailed in Table H4, Column 3)
eststo ExogLeaderLikeT0Green :reg LeaderLike_green_t0 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_green exp_coalition_green pol_interest attitude_debtbrake attitude_elec_integrity[pweight=panel2_weight]
predict LeaderLike_green_t0hat1


** <<< Green: Correlation between Leader Likeability t0 and Exogenized Leader Likeability t0 (Detailed in Table H2, Column 1, Row 3)
corr LeaderLike_green_t0hat1 LeaderLike_green_t1


** <<< FDP: Instrumental Variable Creation of Exogenized Leader Likeability t0 (Detailed in Table H4, Column 4)
eststo ExogLeaderLikeT0FDP :reg LeaderLike_fdp_t0 age female empl_status partner_in_hh church_attendance media_use_tv exp_result_union exp_coalition_union pol_interest attitude_debtbrake attitude_elec_integrity [pweight=panel2_weight]
predict LeaderLike_fdp_t0hat1


** <<< SPD: Correlation between Leader Likeability t0 and Exogenized Leader Likeability t0 (Detailed in Table H2, Column 1, Row 4)
corr LeaderLike_fdp_t0hat1 LeaderLike_fdp_t0


** <<< TRANSFER MODEL OUTPUT TO TABLES IN MS WORD
esttab ExogLeaderLikeT0CDU ExogLeaderLikeT0SPD ExogLeaderLikeT0Green ExogLeaderLikeT0FDP using table_ExogLeaderLikeT0.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H4) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace


********************************************************************************
**// 5.3 INSTRUMENTAL VARIABLES MODELS: WITH PARTY LIKEABILITY T-1 EXOGENIZED
** Analysis for each party detailed in Appendix H - Tables H5.1 and H5.2 & Figure H2
********************************************************************************

** <<< Logit Regression Model With Weights: Union (Table H5.1, Column 1)
eststo ExogPartyUnion :logit vote_union age female high_school church_attendance east lr_self LeaderLike_cdu_t0 PartyLike_cdu_t1hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: FDP (Table H5.2, Row 1)
margins, dydx(LeaderLike_cdu_t0)
margins, dydx(PartyLike_cdu_t1hat1)


** <<<  Predicted Probabilites: Union  (Figure H2, Top Left)
margins, at(LeaderLike_cdu_t0=(0(1)10)) 
margins, at(PartyLike_cdu_t1hat1=(0(1)10)) 


** <<< Logit Regression Model With Weights: SPD (Table H5.1, Column 2)
eststo ExogPartySPD :logit vote_spd age female high_school church_attendance east lr_self LeaderLike_spd_t0 PartyLike_spd_t1hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: SPD (Table H5.2, Row 2)
margins, dydx(LeaderLike_spd_t0)
margins, dydx(PartyLike_spd_t1hat1)


** <<<  Predicted Probabilites: SPD  (Figure H2, Top Right)
margins, at(LeaderLike_spd_t0=(0(1)10)) 
margins, at(PartyLike_spd_t1hat1=(0(1)10)) 


** <<< Logit Regression Model With Weights: Green (Table H5.1, Column 3)
eststo ExogPartyGreen :logit vote_green age female high_school church_attendance east lr_self LeaderLike_green_t0 PartyLike_green_t1hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: Green (Table H5.2, Row 2)
margins, dydx(LeaderLike_green_t0)
margins, dydx(PartyLike_green_t1hat1)


** <<<  Predicted Probabilites: Green  (Figure H2, Bottom)
margins, at(LeaderLike_green_t0=(0(1)10)) 
margins, at(PartyLike_green_t1hat1=(0(1)10)) 


** <<< Logit Regression Model With Weights: FDP (Table H5.1, Column 4)
eststo ExogPartyFDP :logit vote_fdp age female high_school church_attendance east lr_self LeaderLike_fdp_t0 PartyLike_fdp_t1hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: FDP (Table H5.2, Row 4)
margins, dydx(LeaderLike_fdp_t0)
margins, dydx(PartyLike_fdp_t1hat1)


** <<<  Predicted Probabilites: FDP  
margins, at(LeaderLike_fdp_t0=(0(5)10)) 
margins, at(PartyLike_fdp_t1hat1=(0(5)10)) 


** <<< TRANSFER MODEL OUTPUT TO TABLES IN MS WORD
esttab ExogPartyUnion ExogPartySPD ExogPartyGreen ExogPartyFDP using table_ExogParty.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H5) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace


********************************************************************************
**// 5.4 INSTRUMENTAL VARIABLES MODEL WITH LEADER LIKEABILITY T-0 EXOGENIZED
** Analysis for each party detailed in Appendix H - Tables H6.1 and H6.2 
********************************************************************************

** <<< Logit Regression Model With Weights: Union (Table H6.1, Column 1)
eststo ExogLeaderCDU :logit vote_union age female high_school church_attendance east lr_self PartyLike_cdu_t1 LeaderLike_cdu_t0hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: Union (Table H6.2, Row 2)
margins, dydx(PartyLike_cdu_t1)
margins, dydx(LeaderLike_cdu_t0hat1)


** <<<  Predicted Probabilites: Union  
margins, at(PartyLike_cdu_t1=(0(5)10)) 
margins, at(LeaderLike_cdu_t0hat1=(0(5)10)) 


** <<< Logit Regression Model With Weights: SPD (Table H6.1, Column 2)
eststo ExogLeaderSPD :logit vote_spd age female high_school church_attendance east lr_self PartyLike_spd_t1 LeaderLike_spd_t0hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: SPD (Table H6.2, Row 2)
margins, dydx(PartyLike_spd_t1)
margins, dydx(LeaderLike_spd_t0hat1)


** <<<  Predicted Probabilites: SPD  
margins, at(PartyLike_spd_t1=(0(5)10)) 
margins, at(LeaderLike_spd_t0hat1=(0(5)10)) 


** <<< Logit Regression Model With Weights: Green (Table H6.1, Column 3)
eststo ExogLeaderGreen :logit vote_green age female high_school church_attendance east lr_self PartyLike_green_t1 LeaderLike_green_t0hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: Green (Table H6.2, Row 2)
margins, dydx(PartyLike_green_t1)
margins, dydx(LeaderLike_green_t0hat1)


** <<<  Predicted Probabilites: Green  
margins, at(PartyLike_green_t1=(0(5)10)) 
margins, at(LeaderLike_green_t0hat1=(0(5)10)) 


** <<< Logit Regression Model With Weights: FDP (Table H6.1, Column 4)
eststo ExogLeaderFDP :logit vote_fdp age female high_school church_attendance east lr_self PartyLike_fdp_t1 LeaderLike_fdp_t0hat1 [pweight=panel2_weight]
estat ic 


** <<< Average Predicted Probabilites: FDP (Table H6.2, Row 2)
margins, dydx(PartyLike_fdp_t1)
margins, dydx(LeaderLike_fdp_t0hat1)


** <<<  Predicted Probabilites: FDP 
margins, at(PartyLike_fdp_t1=(0(5)10)) 
margins, at(LeaderLike_fdp_t0hat1=(0(5)10)) 


** <<< TRANSFER MODEL OUTPUT TO TABLES IN MS WORD
esttab ExogLeaderCDU ExogLeaderSPD ExogLeaderGreen ExogLeaderFDP using table_ExogLeader.rtf, b(3) se(3) nogap  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) varwidth(25) label title(Table H6) nonumbers mtitles("Union" "SPD" "Green" "FDP") addnote("Source of data: RCS 2021")   replace



********************************************************************************
********************************************************************************
** END OF FILE ** 
********************************************************************************
********************************************************************************
